/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.domain.order;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * Provides an order line item.
 * 
 * @author Scott Rossillo
 *
 */
public class OrderLine implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private CartItem cartItem;
	
	/**
	 * @@BusinessObjectProperty("orl_id")
	 */
	private Long id;
	
	/**
	 * @@BusinessObjectProperty("currency_cd")
	 */
	private String currencyCode;
	
	/**
	 * @@BusinessObjectProperty("status_cd")
	 */
	private String statusCode;
	
	/**
	 * @@BusinessObjectProperty("orl_sku_id")
	 */
	private long skuId;
	
	/**
	 * @@BusinessObjectProperty("prd_id")
	 */
	private long productId;
	
	/**
	 * @@BusinessObjectProperty("orl_prm_id")
	 */
	private long promotionId;
	
	private String productCode;
	
	private int sequence;
	private int quantity;
	private int backupQuantity;
	
	private boolean taxable;
	
	/**
	 * @@BusinessObjectProperty("shortDesc")
	 */
	private String description;
	
	/**
	 * @@BusinessObjectProperty("extendedPriceAmt")
	 */
	private BigDecimal extendedPrice;
	
	/**
	 * @@BusinessObjectProperty("listPriceAmt")
	 */
	private BigDecimal listPrice;
	
	/**
	 * @@BusinessObjectProperty("salePriceAmt")
	 */
	private BigDecimal salePrice;
	
	/**
	 * @@BusinessObjectProperty("unitPriceAmt")
	 */
	private BigDecimal unitPrice;
	
	/**
	 * @@BusinessObjectProperty("CostPrice", attribute=true)
	 */
	private Double costPrice;
	
	/**
	 * @@BusinessObjectProperty("systemUnitPriceAmt")
	 */
	private BigDecimal systemUnitPrice;
	
	/**
	 * @@BusinessObjectProperty("systemExtendedPriceAmt")
	 */
	private BigDecimal systemExtendedPrice;
	
	/**
	 * line discount is only really used for internal
	 * calculations, we don't save in in the database, 
	 * as the order fulfillment systems don't use it
	 */
	private BigDecimal discount;
	
	private Long shipToId;
	private Long shipMethod;
	
	private Integer planShipmentIndex;
	
	/**
	 * Creates a new order line.
	 */
	public OrderLine() { 
		
		extendedPrice = BigDecimal.valueOf(0L, 2);
		listPrice = BigDecimal.valueOf(0L, 2);
		salePrice = BigDecimal.valueOf(0L, 2);
		unitPrice = BigDecimal.valueOf(0L, 2);
		
		systemUnitPrice = BigDecimal.valueOf(0L, 2);
		systemExtendedPrice = BigDecimal.valueOf(0L, 2);
		
		this.taxable = true;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public CartItem getCartItem() {
		return cartItem;
	}

	public long getSkuId() {
		return skuId;
	}

	public void setSkuId(long skuId) {
		this.skuId = skuId;
	}

	public long getProductId() {
		return productId;
	}

	public void setProductId(long productId) {
		this.productId = productId;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public BigDecimal getExtendedPrice() {
		return extendedPrice;
	}

	public void setExtendedPrice(BigDecimal extendedPrice) {
		this.extendedPrice = extendedPrice;
	}

	public BigDecimal getListPrice() {
		return listPrice;
	}

	public void setListPrice(BigDecimal listPrice) {
		this.listPrice = listPrice;
	}

	public BigDecimal getSalePrice() {
		return salePrice;
	}

	public void setSalePrice(BigDecimal salePrice) {
		this.salePrice = salePrice;
	}

	public BigDecimal getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(BigDecimal unitPrice) {
		this.unitPrice = unitPrice;
	}

	public void setCartItem(CartItem cartItem) {
		this.cartItem = cartItem;
	}

	public String getCurrencyCode() {
		return currencyCode;
	}

	public void setCurrencyCode(String currencyCode) {
		this.currencyCode = currencyCode;
	}

	public String getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	public int getBackupQuantity() {
		return backupQuantity;
	}

	public void setBackupQuantity(int backupQuantity) {
		this.backupQuantity = backupQuantity;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public BigDecimal getSystemUnitPrice() {
		return systemUnitPrice;
	}

	public void setSystemUnitPrice(BigDecimal systemUnitPrice) {
		this.systemUnitPrice = systemUnitPrice;
	}

	public BigDecimal getSystemExtendedPrice() {
		return systemExtendedPrice;
	}

	public void setSystemExtendedPrice(BigDecimal systemExtendedPrice) {
		this.systemExtendedPrice = systemExtendedPrice;
	}

	public BigDecimal getDiscount() {
		return discount;
	}

	public void setDiscount(BigDecimal discount) {
		this.discount = discount;
	}

	public long getPromotionId() {
		return promotionId;
	}

	public void setPromotionId(long promotionId) {
		this.promotionId = promotionId;
	}

	public Long getShipToId() {
		return shipToId;
	}

	public void setShipToId(Long shipToId) {
		this.shipToId = shipToId;
	}

	public Long getShipMethod() {
		return shipMethod;
	}

	public void setShipMethod(Long shipMethod) {
		this.shipMethod = shipMethod;
	}

	public Integer getPlanShipmentIndex() {
		return planShipmentIndex;
	}

	public void setPlanShipmentIndex(Integer planShipmentIndex) {
		this.planShipmentIndex = planShipmentIndex;
	}

	public Double getCostPrice() {
		return costPrice;
	}

	public void setCostPrice(Double costPrice) {
		this.costPrice = costPrice;
	}

	/**
	 * Returns true if this order line is taxable.
	 * 
	 * @return <code>true</code> if this line is taxable;
	 * <code>false</code> otherwise 
	 */
	public boolean isTaxable() {
		return taxable;
	}
	
	/**
	 * Sets whether or not this order line is taxable.
	 * 
	 * @return <code>true</code> if this line is taxable;
	 * <code>false</code> otherwise 
	 */
	public void setTaxable(boolean taxable) {
		this.taxable = taxable;
	}

}
